
import java.util.List;

import models.User;
import models.Event;
import play.jobs.Job;
import play.jobs.OnApplicationStart;
import play.test.Fixtures;

@OnApplicationStart
public class Bootstrap extends Job {
	public void doJob() {
		if(User.count() == 0) {
			Fixtures.loadModels("user.yml");
		}
		//if(Event.count() == 0) {
		//    Fixtures.loadModels("event.yml");
		//}
		List<Event> events = Event.find("select e from Event e where e.eventDate >= CURRENT_DATE").fetch();
		for (Event event: events)
		{
			event.selected = false;
			event.save();
		}		
		Event.em().flush();
	}
}
